/**
 * Copyright 2015 Qiyi Inc. All rights reserved.
 *
 * @file:   Carousel.Config.js
 * @author: karkarrotxu@qiyi.com
 * @date:   2016-05-30
 */
qui(
    function (require, exports, module) {
        Carousel.Config = $.extend({}, Ancestor.Config, {
            TABLE_COLMODEL_CONFIG: {
                index: {
                    name: "index",
                    index: 'index',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    editable: true,
                    edittype: "text",
                    editrules: {
                        custom: true,
                        custom_func: function (value, colName) {
                            if (value == null) {
                                return [false, ""];
                            }
                            if (!/^[1-9]\d*$/.test(value)) {
                                return [false, "请输入正整数"];
                            }
                            var obj = $("#list").jqGrid("getRowData");
                            if (parseInt(value, 10) > obj.length) {
                                return [false, "长度越界"];
                            }
                            console.log("editrules excute");
                            return [true, ""];
                        }
                    }
                },
                qipuId: {
                    name: "qipuId",
                    index: 'qipuId',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.qipuId(cellvalue, options, rowObject);
                    }
                },
                qipuIdNew: {
                    name: "qipuId",
                    index: 'qipuId',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.qipuIdNew(cellvalue, options, rowObject);
                    }
                },
                displayName: {
                    name: "displayName",
                    index: 'displayName',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.wrapColor(rowObject, cellvalue)
                    }
                },
                programName: {
                    name: "programName",
                    index: 'programName',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center"
                },
                twProgramName: {
                    name: "twProgramName",
                    index: 'twProgramName',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center",
                    formatter: function(cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.twProgramName(cellvalue, options, rowObject);
                    }
                },
                albumId: {//专辑ID
                    name: "albumId",
                    index: 'albumId',
                    title: false,
                    width: 100,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return  Carousel.Util.formatter.albumId(cellvalue, options, rowObject);
                    }
                },
                channelName: {
                    name: "channelName",
                    index: 'channelName',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.wrapColor(rowObject, cellvalue)
                    }
                },
                twChannelName: {
                    name: "twChannelName",
                    index: 'twChannelName',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.twChannelName(cellvalue, options, rowObject)
                    }
                },

                channelName2: {
                    //所属频道
                    name: "channelName",
                    index: 'channelName',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center"
                },

                globalPublishDate: {
                    name: "globalPublishDate",
                    index: 'globalPublishDate',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.wrapColor(rowObject, cellvalue == null ? "" : cellvalue)
                    }
                },
                duration: {
                    name: "duration",
                    index: 'duration',
                    title: false,
                    width: 60,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        var calculateDuration = ( cellvalue / 1000 >> 0);
                        return Carousel.Util.formatter.wrapColor(rowObject, Carousel.Util.tranDurationFormat(calculateDuration));
                    }
                },
                pagePublishStatus: {
                    name: "pagePublishStatus",
                    index: 'pagePublishStatus',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.wrapColor(rowObject, Carousel.Util.formatter.publishStatus(cellvalue));
                    }
                },
                copyrightEndTime: {
                    name: "copyrightEndTime",
                    index: 'copyrightEndTime',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.wrapColor(rowObject, Carousel.Util.formatter.copyrightEndTime(cellvalue));
                    }
                },
                purchase: {
                    name: "bossStatus",
                    index: 'bossStatus',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    hidden: true,
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.wrapColor(rowObject, Carousel.Util.formatter.purchase(cellvalue));
                    }
                },
                pname: {
                    name: "pname",
                    index: 'pname',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center"
                },

                pnameNew: {
                    name: "pname",
                    index: 'pname',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.pnameNew(cellvalue, options, rowObject);
                    }
                },
                referContentType: {
                    name: "referContentType",
                    index: 'referContentType',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.referContentType(cellvalue, options, rowObject);
                    }
                },
                albumName: {
                    name: "albumName",
                    index: 'albumName',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center"
                },
                twAlbumName: {
                    name: "twAlbumName",
                    index: 'twAlbumName',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center",
                    formatter: function(cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.twProgramName(cellvalue, options, rowObject);
                    }
                },
                startPlayTime: {
                    name: "startPlayTime",
                    index: 'startPlayTime',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center"
                },
                endPlayTime: {
                    name: "endPlayTime",
                    index: 'endPlayTime',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center"
                },
                live: {
                    name: "live",
                    index: 'live',
                    title: false,
                    width: 100,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.live(cellvalue, options, rowObject);
                    }
                },
                type: {
                    name: "type",
                    index: 'type',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.type(cellvalue, options, rowObject);
                    }
                },
                itemTime: {
                    index: 'itemTime',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        var duration = (new Date(rowObject.endPlayTime.replace(/-/g, "/")).getTime() - new Date(rowObject.startPlayTime.replace(/-/g, "/")).getTime()) / 1000;
                        return Carousel.Util.tranDurationFormat(duration);
                    }
                },
                bossStatus: {
                    name: "bossStatus",
                    index: 'bossStatus',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.bossStatus(cellvalue, options, rowObject);
                    }
                },
                updateTime: {
                    name: "updateTime",
                    index: 'updateTime',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center"
                },
                hiddenData_LIST: {
                    name: "hiddenData",
                    index: "hiddenData",
                    title: false,
                    hidden: true,
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.hiddenData_list(cellvalue, options, rowObject);

                    }
                },
                operator: {
                    title: false,
                    width: 260,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.operator(cellvalue, options, rowObject);
                    }
                },

                opUser: {
                    name: "opUser",
                    index: 'opUser',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center"
                },
                sortIndex: {
                    name: "index",
                    index: 'index',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    editable: true,
                    edittype: "text",
                    editrules: {
                        custom: true,
                        custom_func: function (value, colName) {
                            if (!/^[1-9]\d*$/.test(value)) {
                                return [false, "请输入正整数"];
                            }
                            console.log("editrules excute");
                            //Carousel.
                            return [true, ""];
                        }
                    }
                },
                hiddenData_carousel_episode: {
                    name: "hiddenData",
                    index: "hiddenData",
                    title: false,
                    hidden: true,
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.hiddenData_carousel_episode(cellvalue, options, rowObject);
                    }
                },

                showName: {
                    name: "showName",
                    index: 'showName',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.showName(cellvalue, options, rowObject);
                    }
                },
                channelTag: {
                    name: "channelTag",
                    index: 'channelTag',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center"
                },
                publishStatus: {
                    name: "publishStatus",
                    index: 'publishStatus',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.publishStatus(cellvalue);
                    }
                },
                bossStatus_rule: {
                    name: "bossStatus",
                    index: 'bossStatus',
                    title: false,
                    width: 60,
                    sortable: false,
                    align: "center",
                    //(1：免费 2：收费)
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.bossStatus_rule(cellvalue, options, rowObject);
                    }
                },
                startTime: {
                    name: "startTime",
                    index: 'startTime',
                    title: false,
                    width: 160,
                    sortable: false,
                    align: "center"
                },
                endTime: {
                    name: "endTime",
                    index: 'endTime',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.endTime(cellvalue, options, rowObject);
                    }
                },
                type_rule: {
                    name: "type",
                    index: 'type',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.type_rule(cellvalue, options, rowObject);
                    }
                },
                followedStatus: {
                    name: "followedStatus",
                    index: 'followedStatus',
                    title: false,
                    width: 60,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.followedStatus(cellvalue, options, rowObject);
                    }
                },
                followNum: {
                    name: "followNum",
                    index: 'followNum',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center"
                },
                repeatedStatus: {
                    name: "repeatedStatus",
                    index: 'repeatedStatus',
                    title: false,
                    width: 60,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.repeatedStatus(cellvalue, options, rowObject);
                    }
                },
                currentDisplay: {
                    index: 'currentDisplay',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.currentDisplay(cellvalue, options, rowObject);
                    }
                },
                totalNum: {
                    name: "totalNum",
                    index: 'totalNum',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center"
                },
                restDay: {
                    index: 'rest',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.restDay(cellvalue, options, rowObject);
                    }
                },
                operator_rule: {
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.operator_rule(cellvalue, options, rowObject);
                    }
                },
                hiddenData_rule: {
                    name: "hiddenData",
                    index: "hiddenData",
                    title: false,
                    hidden: true,
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.hiddenData_rule(cellvalue, options, rowObject);
                    }
                },
                operator_carousel_episode: {
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return Carousel.Util.formatter.operator_carousel_episode(cellvalue, options, rowObject);
                    }
                },
                createdTime: {
                    name: "createdTime",
                    index: 'createdTime',
                    title: false,
                    width: 120,
                    sortable: false,
                    align: "center"
                },
                log_id: {
                    name: 'id',
                    index: 'id',
                    title: false,
                    sortable: false,
                    hidden: true
                },
                log_addTime: {
                    name: 'addTime',
                    index: 'addTime',
                    sortable: false,
                    title: false,
                    width: 150,
                    align: 'center'
                },
                log_user: {
                    name: 'user',
                    index: 'user',
                    sortable: false,
                    title: false,
                    width: 150
                },
                log_type: {
                    name: 'type',
                    index: 'type',
                    sortable: false,
                    title: false,
                    width: 120,
                    formatter: function (v, o, r) {
                        return Carousel.Util.formatter.log_type(v, o, r);
                    }
                },
                log_descr: {
                    name: "descr",
                    index: 'descr',
                    title: false,
                    width: 450,
                    sortable: false
                },

                advertEnable: {
                    name: 'advertEnable',
                    index: 'advertEnable',
                    sortable: false,
                    title: false,
                    width: 120,
                    align: "center",
                    formatter: function (v, o, r) {
                        return Carousel.Util.formatter.advertEnable(v, o, r);
                    }
                },
                actualNum: {
                    name: "actualNum",
                    index: 'actualNum',
                    title: false,
                    width: 80,
                    align: "center",
                    sortable: false
                },
                status_automation_rule: {
                    name: "status",
                    index: 'status',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    formatter: function (v, o, r) {
                        return Carousel.Util.formatter.status_automation_rule(v, o, r);
                    }
                },
                operator_automation_rule: {
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    formatter: function (v, o, r) {
                        return Carousel.Util.formatter.operator_automation_rule(v, o, r);
                    }
                },
                currentExec: {
                    name: "currentExec",
                    index: 'currentExec',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    formatter: function (v, o, r) {
                        return Carousel.Util.formatter.currentExec(v, o, r);
                    }
                },
                publishStatus_automation_rule:           {
                    name: "publishStatus",
                    index: 'publishStatus',
                    title: false,
                    width: 80,
                    sortable: false,
                    align: "center",
                    formatter:function (v, o, r) {
                        return Carousel.Util.formatter.publishStatus_automation_rule(v, o, r);
                    }
                    //1：未发布 2：已发布)

                }
            },


            TABLE_LIST: {
                loadBeforeSend: function (xhr, settings) {
                    xhr.setRequestHeader("Sign", "#f93Uc31K24()_@");
                    return true;
                },
                beforeSelectRow: function (rowid, e) {
                    if (JSON.parse($("#" + this.id).getRowData(rowid).hiddenData).lockStatus == 1) {
                        return false;
                    }
                    if (e.target.localName === 'input' || e.target.getAttribute("aria-describedby") === this.id + "_index") {
                        return true;
                    }
                },
                beforeProcessing: function (gdata, status, xhr) {
                    var listData = gdata.data;
                    var filterResult = listData.result;
                    $.ajax({
                        type: "post",
                        url: EpgWeb.urlConfig.yesterdayEndTimeUrl,
                        beforeSend: function (request) {
                            request.setRequestHeader("Sign", "#f93Uc31K24()_@");
                        },
                        dataType: "json",
                        data: {channelId: Carousel.Dao.channelId, newStartTime: new Date((Carousel.Config.dateTime + " 00:00:00").replace(/-/g, "/")).getTime()  },
                        success: function (data) {
                            if (data.code === "A00000") {
                                Carousel.Dao.cfgName.yesterdayEndTime = Carousel.Util.formatDateTimeFormat(new Date(data.data));
                                console.log(" Carousel.memo.yesterdayEndTime:" + Carousel.Dao.cfgName.yesterdayEndTime);
                            }
                            Carousel.Dao.putToCache("originalArr", filterResult);
                            var rest = listData.totalCount % listData.pageSize;
                            listData.totalPages = (listData.totalCount - rest ) / listData.pageSize + (rest == 0 ? 0 : 1);
                            var fillData = {"total": listData.totalPages, "page": listData.pageNo, "records": listData.totalCount, "rows": filterResult};
                            $("#list")[0].addJSONData(fillData);
                            Carousel.Util.showNoResult(fillData.rows.length);
                            Carousel.Util.recordDuration(filterResult);
                            Carousel.Util.setColorTime(filterResult);
                            Carousel.Util.addBreakHint(filterResult);
                            Carousel.Util.fillLineNo();
                            Carousel.Util.checkSelectAble(filterResult);
                        }
                    })
                    return false;
                },
                jsonReader: {
                    id: "id",
                    root: "rows",
                    page: "page",
                    total: "total",
                    records: "records"
                },
                cellEdit: true,
                cellsubmit: 'clientArray',
                afterSaveCell: function (rowid, cellname, value, iRow, iCol) {
                    console.log("afterSaveCell value:" + value);
                    var dataOriginal = Carousel.Dao.getFromCache("originalArr");
                    var targetElement = dataOriginal[value - 1];
                    console.log("id" + rowid + ";aimid" + targetElement.id);
                    Carousel.Util.programIndexMove(rowid, targetElement.id);
                },
                afterEditCell: function (rowid, cellname, value, iRow, iCol) {
                    var inputCell = $("#list").find("input[name=index]");
                    inputCell.focusout(function (event) {
                        setTimeout(function () {
                            var e = jQuery.Event("keydown");
                            e.keyCode = 13;
                            $(event.currentTarget).trigger(e);
                        }, 100)
                    });
                },
                loadComplete: function () {
                    var jqGridTarget = $("#list");
                    var re_records = jqGridTarget.getGridParam('records');
                    Carousel.Util.showNoResult((re_records == 0 || re_records == null) ? 0 : 1);
                },
                beforeEditCell: function (rowid, cellname, value, iRow, iCol) {
                    console.log(" beforeEditCell ");
                    var currentDay = new Date();
                    currentDay.setTime(currentDay.getTime() + 30 * 60 * 1000)
                    var checkTime = Carousel.Util.formatDateTimeFormat(currentDay);
                    var jqGridTarget = $("#list");
                    var element = jqGridTarget.getRowData(rowid);
                    var hiddenData = JSON.parse(element.hiddenData);
                    var checkObj = {};
                    if (hiddenData.lockStatus == 1) {
                        checkObj.msg = Carousel.Config.EditErrorMsg.ERROR_LOCK;
                    } else if (element.live !== "点播") {
                        checkObj.msg = Carousel.Config.EditErrorMsg.ERROR_NOT_SUPPORT;
                    } else if (element.startPlayTime < checkTime) {
                        checkObj.msg = Carousel.Config.EditErrorMsg.ERROR_NOT_ALLOWED;
                    }
                    if (checkObj.msg != null) {
                        EpgWeb.Plugin.showTips({content: checkObj.msg, type: "error" });
                        setTimeout(function () {
                            jqGridTarget.restoreCell(iRow, iCol);
                        }, 50);
                    } else {
                        setTimeout(function () {
                            jqGridTarget.find("#" + rowid).find("td:eq(" + iCol + ")").find("input").select();
                        }, 50);
                    }
                },
                prmNames: {
                    page: "pageNo",
                    rows: "pageSize"
                },
                multiselect: true,
                mtype: "post",
                datatype: "local",
                height: 450,
                rowNum: 500,
                caption: "节目单列表",
                colNames: ["序号", "奇谱ID", "节目名称", "内容类型", "所属专辑", "是否包含广告点", "开始时间", "结束时间", "播放类型", "节目类型", "付费状态", "更新日期", "隐藏数据", "操作"],
                colModel: ["index", "qipuIdNew", "pnameNew", "referContentType", "albumName", "advertEnable", "startPlayTime", "endPlayTime", "live", "type", "bossStatus", "updateTime", "hiddenData_LIST", "operator"],
                pager: "#pager",
                toolbar: [true, "top"]
            },

            TABLE_LIST_ADD_TYPE1: {
                loadBeforeSend: function (xhr, settings) {
                    xhr.setRequestHeader("Sign", "#f93Uc31K24()_@");
                    return true;
                },
                beforeProcessing: function (data, status, xhr) {
                    var self = this;
                    if (data != null && data.data != null) {
                        Carousel.Util.checkQipuPlatformControl(function (data) {
                            var filterResult = [];
                            $.each(data.result, function (i, element) {
                                if (!element.illegal) {
                                    filterResult.push(element)
                                } else {
                                    console.log("illegal:" + element.qipuId);
                                }
                            })
                            var fillData = {"total": data.totalPages, "page": data.pageNo, "records": data.totalCount, "rows": filterResult};
                            Carousel.Dao.putToCache("gridData1", fillData);
                            $("#listAdd1")[0].addJSONData(fillData);
                            Carousel.Util.showNoResult(fillData.rows.length, "#listAdd1");
                        }, data.data)
                    } else {
                        var msg = "接口url：" + EpgWeb.Constant.thirdUrl_apis_search_area_url + ";<br>" + (data == null ? "请求lego接口失败" : data.msg);
                        SystemDialog.queryAlert(msg);
                        console.log("错误信息:" + JSON.stringify(data));
                    }
                    return false;
                },
                serializeGridData: function (postData) {
                    if (postData.request != null) {
                        var requestData = JSON.parse(postData.request);
                        requestData.params["page.pageNo"] = postData["page.pageNo"];
                        postData.request = JSON.stringify(requestData)
                    }
                    return postData
                },
                jsonReader: {
                    id: "qipuId",
                    root: "rows",
                    page: "page",
                    total: "total",
                    records: "records"
                },
                multiselect: true,
                mtype: "post",
                datatype: "local",
                width: 1300,
                height: 450,
                rowNum: 30,
                caption: "点播列表",
                colNames: ["奇谱ID", "节目名称", "专辑ID", "频道", "发行时间", "时长", "发布状态", "版权到期时间", "付费"],
                colModel: ["qipuId", "displayName", "albumId", "channelName", "globalPublishDate", "duration", "pagePublishStatus", "copyrightEndTime", "purchase"],
                pager: "#pagerAdd1"
            },
            TABLE_LIST_ADD_TYPE2: {
                loadBeforeSend: function (xhr, settings) {
                    xhr.setRequestHeader("Sign", "#f93Uc31K24()_@");
                    return true;
                },
                jsonReader: {
                    id: "qipuId"
                },
                multiselect: true,
                loadComplete: function () {
                    var jqGridTarget = $("#listAdd2");
                    var re_records = jqGridTarget.getGridParam('records');
                    var parentElement = jqGridTarget.parent()
                    var dataLength = re_records == 0 || re_records == null ? 0 : re_records;
                    Carousel.Util.showNoResult(dataLength, "#listAdd2");
                },
                mtype: "post",
                datatype: "local",
                prmNames: {
                    page: "pageNo",
                    rows: "pageSize"
                },
                width: 860,
                height: 450,
                rowNum: 50,
                caption: "直播列表",
                colNames: ["奇谱ID", "节目名称", "开始时间", "结束时间", "时长", "节目类型", "付费", "所属频道"],
                colModel: ["qipuId", "pname", "startPlayTime", "endPlayTime", "itemTime", "type", "bossStatus", "channelName2"],
                pager: "#pagerAdd2"
            },

            TABLE_LIBRARY: {
                url: EpgWeb.urlConfig.carouselEpisodeListUrl,
                loadBeforeSend: function (xhr, settings) {
                    xhr.setRequestHeader("Sign", "#f93Uc31K24()_@");
                    return true;
                },
                beforeSelectRow: function (rowid, e) {
                    if (Carousel.Config.IS_RULE_RUNNING) {
                        return false;
                    }
                    if (e.target.localName === 'input' || e.target.getAttribute("aria-describedby") === this.id + "_index") {
                        return true;
                    }
                },
                cellEdit: true,
                cellsubmit: 'clientArray',
                afterSaveCell: function (rowid, cellname, value, iRow, iCol) {
                    console.log("afterSaveCell value:" + value);
                    var params = $("#list").jqGrid("getGridParam");
                    var selIdx = (params.page - 1) * params.rowNum + iRow;
                    if (selIdx > value) {
                        value--;
                    }
                    console.log("id" + rowid + "; aimIdx:" + value);
                    Carousel.Util.episodeIndexMove(rowid, value);
                    // Carousel.Operation.indexMove(rowid, targetElementId);
                },
                //   cellurl: Carousel.urlConfig.programIndexMoveUrl,
                afterEditCell: function (rowid, cellname, value, iRow, iCol) {
                    var inputCell = $("#" + this.id).find("input[name=index]");
                    inputCell.focusout(function (event) {
                        setTimeout(function () {
                            var e = jQuery.Event("keydown");
                            e.keyCode = 13;
                            $(event.currentTarget).trigger(e);
                        }, 100)
                    });
                },
                loadComplete: function () {
                    var jqGridTarget = $("#list");
                    var re_records = jqGridTarget.getGridParam('records');
                    Carousel.Util.showNoResult((re_records == 0 || re_records == null) ? 0 : 1);
                    Carousel.Util.toggleTwColumns();
                    Carousel.Util.fillLineNo();
                },
                prmNames: {
                    page: "pageNo",
                    rows: "pageSize"
                },
                multiselect: true,
                mtype: "get",
                datatype: "local",
                width: 1300,
                height: 450,
                rowNum: 30,
                caption: "循环节目列表",
                //
                colNames: ["序号", "节目奇谱ID", "节目名称", "专辑", "频道","节目名称", "专辑", "频道", "操作", "操作人", "操作时间", "发行时间", "时长", "发布状态", "版权到期时间", "付费", "隐藏数据"],
                colModel: ["sortIndex", "qipuId", "programName", "albumName", "channelName", "twProgramName", "twAlbumName", "twChannelName", "operator_carousel_episode", "opUser", "createdTime", "globalPublishDate", "duration", "pagePublishStatus", "copyrightEndTime", "purchase", "hiddenData_carousel_episode"],
                pager: "#pager"
            },
            TABLE_RUN: {
                loadBeforeSend: function (xhr, settings) {
                    xhr.setRequestHeader("Sign", "#f93Uc31K24()_@");
                    return true;
                },
                loadComplete: function () {
                    var dataOriginl = $("#list").jqGrid("getRowData");
                    if (dataOriginl == null || dataOriginl.length == 0) {
                        return;
                    }
                    Carousel.Util.checkSelectAble(dataOriginl);
                },
                beforeSelectRow: function (rowid, e) {
                    if (e.target.localName === 'input') {
                        return true;
                    }
                },
                multiselect: true,
                mtype: "post",
                datatype: "json",
                width: 1380,
                height: 450,
                prmNames: {
                    page: "pageNo",
                    rows: "pageSize"
                },
                rowNum: 20,
                caption: "规则列表",
                colNames: ["奇谱ID", "显示名称", "频道", "状态", "付费", "开始时间", "结束时间", "类型", "跟播", "连播", "循环播放", "当前", "总集数", "到期", "操作", "隐藏数据"],
                colModel: ["qipuId", "showName", "channelTag", "publishStatus", "bossStatus_rule", "startTime", "endTime", "type_rule", "followedStatus", "followNum", "repeatedStatus", "currentDisplay", "totalNum", "restDay", "operator_rule", "hiddenData_rule"],
                pager: "#pager"
            },
            TABLE_AUTOMATION_RULE: {
                loadBeforeSend: function (xhr, settings) {
                    xhr.setRequestHeader("Sign", "#f93Uc31K24()_@");
                    return true;
                },
                beforeSelectRow: function (rowid, e) {
                    if (JSON.parse($("#ruleList").getRowData(rowid).hiddenData).status == 1) {
                        return false;
                    }
                    if (e.target.localName === 'input' || e.target.getAttribute("aria-describedby") === "ruleList_index") {
                        return true;
                    }
                },

                cellEdit: true,
                cellsubmit: 'clientArray',
                afterSaveCell: function (rowid, cellname, value, iRow, iCol) {
                    console.log("afterSaveCell value:" + value);
                    value--;
                    console.log("id" + rowid + "; aimIdx:" + value);
                    //   Carousel.Operation.indexMove(rowid, targetElementId);
                },
                //   cellurl: Carousel.urlConfig.programIndexMoveUrl,
                afterEditCell: function (rowid, cellname, value, iRow, iCol) {
                    var inputCell = $("#ruleList").find("input[name=index]");
                    inputCell.focusout(function (event) {
                        setTimeout(function () {
                            var e = jQuery.Event("keydown");
                            e.keyCode = 13;
                            $(event.currentTarget).trigger(e);
                        }, 100)
                    });
                },
                loadComplete: function () {
                    var jqGridTarget = $("#ruleList");
                    var re_records = jqGridTarget.getGridParam('records');
                    Carousel.Util.showNoResult((re_records == 0 || re_records == null) ? 0 : 1, "#ruleList");
                    Carousel.Util.fillLineNo("#ruleList");
                    Carousel.Util.notifyChangeBtnStatus("#ruleList");
                },
                multiselect: true,
                mtype: "get",
                datatype: "local",
                width: 1380,
                height: 450,
                prmNames: {
                    page: "pageNo",
                    rows: "pageSize"
                },
                rowNum: 20,
                caption: "规则列表",
                colNames: ["序号", "奇谱ID", "显示名称", "频道", "发布状态", "付费", "设定总集数", "实际总集数", "操作", "规则状态", "最近执行", "隐藏数据"],
                colModel: ["sortIndex", "qipuId", "showName", "channelTag", "publishStatus", "bossStatus_rule", "totalNum", "actualNum", "operator_automation_rule" , "status_automation_rule", "currentExec", "hiddenData_carousel_episode"],
                pager: "#pagerAutoRule"
            },
            TABLE_LOG: {
                url: EpgWeb.urlConfig.programLog,
                loadBeforeSend: function (xhr, settings) {
                    var auth = Ancestor.Util.getAuth("/program/loglist");
                    xhr.setRequestHeader('Sign', auth.sign);
                    xhr.setRequestHeader("Time", auth.clientTime);
                    xhr.setRequestHeader("From", auth.from);
                    return true;
                },
                multiselect: false,
                loadtext: '加载中...',
                loadui: 'block',
                rowNum: 50,
                mtype: "post",
                datatype: "local",
                prmNames: {
                    page: "pageNo",
                    rows: "pageSize"
                },
                colNames: ["ID", "操作时间", "人员", "动作", "备注"],
                colModel: ['log_id', "log_addTime", "log_user" , "log_type" , "log_descr"],
                pager: "#log_pager"
            },

            ErrorMsg: {
                PPS_CLIENT_MSG: "该专辑在PPS端没有上线，但会在PPS平台播出，是否确认添加？",
                PPS_REGION_MSG: "该专辑在PPS端有地域播控，但会在PPS平台全地域播出，是否确认添加？",
                QIYI_CLIENT_MSG: "该专辑在QIYI端没有上线，但会在QIYI平台播出，是否确认添加？",
                QIYI_REGION_MSG: "该专辑在QIYI端有地域播控，但会在QIYI平台全地域播出，是否确认添加？"

            },
            Hint: {
                QUERY_ADD: "是否确认添加？",
                NOT_CAROUSEL: "当前频道不是轮播台",
                NO_AUTH: "很抱歉，您没有删除的权限!",
                QUERY_DEL: "确认删除？",
                PPS_CLIENT_HINT: "在PPS端没有上线，但会在PPS平台播出",
                PPS_REGION_HINT: "在PPS端有地域播控，但会在PPS平台全地域播出",
                QIYI_CLIENT_HINT: "在IQIYI端没有上线，但会在IQIYI平台播出",
                QIYI_REGION_HINT: "在IQIYI端有地域播控，但会在IQIYI平台全地域播出",
                STOP_RULE_HINT: "是否确认停止运行自动化规则？停止后已生成的节目单将会在新规则重新运行时被清空，并按新规则重新生成节目单。"
            },
            EditErrorMsg: {
                ERROR_LOCK: "锁定的节目无法排序",
                ERROR_NOT_SUPPORT: "直播节目不支持索引调整",
                ERROR_NOT_ALLOWED: "节目已播放完毕或正在播放中，不可修改。"
            },
            Header: {
                daojuSuggest: ["道具渠道号", "道具渠道名称", "创建时间", "创建人"],
                voteSuggest: ["投票ID", "投票名称", "创建时间"],
                puyuSuggest: ["条形码", "片名", "出品方", "发行时间", "主演 /演唱者", "导演", "版权方", "合同编号", "授权起止时间"],
                albumSuggest: ["奇谱ID", "显示名称", "频道", "版权到期时间", "是否付费", "发布状态"],
                qitanSuggest: ["评论ID", "评论名称", "创建时间"],
                actorSuggest: ["人物ID", "名称", "别名", "性别", "人物类型", "审核状态"],
                playbackSuggest: ["节目Id", "节目显示名称", "频道", "发行时间", "是否付费", "发布状态"]
            },
            ChangeStatus: {
                STATUS_ILLEGAL: -2,
                STATUS_DELETE: -1,
                STATUS_IDLE: 0,
                STATUS_RUN: 1,
                STATUS_PROGRAM_IDLE: 3,
                STATUS_PROGRAM_RUN: 2
            },
            durationMap: null,
            dateTime: null,
            saveIds: null,
            sequeueArr: [],
            invalidArr: null,
            timerId: -1,
            lockFlag: false,
            ruleSelectElement: null,
            IS_RULE_RUNNING: true,
            BIND_BATCH_ADD_MODEL: null,
            AUTH_LOG_DETAIL: false
        })
    }
);